from typing import Optional

from sqlmodel import SQLModel, Field

from app.models.base import IdType


class UserRole(SQLModel, table=True):
    __tablename__ = "user_role"
    user_id: Optional[IdType] = Field(
        default=None,
        nullable=False,
        index=True,
        foreign_key="user.id",
        primary_key=True,
    )
    role_id: Optional[IdType] = Field(
        default=None,
        nullable=False,
        index=True,
        foreign_key="role.id",
        primary_key=True,
    )
